﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Web;

namespace CustomControllerFactory
{
    public class ServiceAttribute : Attribute
    {
        private string _serviceName;
        private string _serviceNamespace;
        public ServiceAttribute(string serviceName, string serviceNamespace)
        {
            _serviceName = serviceName;
            _serviceNamespace = serviceNamespace;
        }

        public string ServiceName
        {
            get { return _serviceName; }
        }

        public string ServiceNameSpace
        {
            get { return _serviceNamespace; }
        }
    }


     [Service(serviceName: "CustomControllerFactory.AddService", serviceNamespace: "CustomControllerFactory")]
     public interface IAddService
     {
         int Add(int a, int b);
     }

    public class AddService : IAddService
    {
        public int Add(int a, int b)
        {
            return a + b;
        }
    }

    [Service(serviceName: "CustomControllerFactory.LoggerService", serviceNamespace: "CustomControllerFactory")]
    public interface ILoggerService
    {
        void Logger(string info);
        string GetLogger();
    }

    public class LoggerService : ILoggerService
    {
        private string _info;
        public string GetLogger()
        {
            return _info;
        }

        public void Logger(string info)
        {
            _info = info;
            string fileName = System.AppDomain.CurrentDomain.BaseDirectory +  "log.txt";
            File.AppendAllText(fileName,info+ System.Environment.NewLine);
        }
    }
}